package day1220;



public class Test7 {
    public static void main(String[] args) {
        double rs=calc(4, ",", 7);//1.自己给方法传入数据  //5.自己在 calc() 左边定义变量接收结果
        System.out.println(rs);//  2.自己写打印
    }
    //     3.修改返回值
    static  double   calc(double  m ,    String operator     ,double n){
        //用operator判断:     operator .equals("+")
        if( operator.equals("+") ){
            return m+n;//4.自己添加return
        }else if( operator.equals("-") ){
            return m+-n;
        }else if(operator.equals("*")){
            return m*n;
        }else if(operator.equals("/")){
            return m/n;
        }else if(operator.equals("%")){
            return m%n;
        }else{
            System.out.println("输入有误，无法计算");
            return -1;
        }
    }


}









